package cn.like.factory;

import cn.hutool.captcha.AbstractCaptcha;
import cn.hutool.core.util.NumberUtil;
import cn.like.util.CaptchaCreator;

/**
 * @author like 980650920@qq.com
 * @date 2021/7/13 13:38
 */
public class CaptchaFactory {

    public static class Type {
        public static final int shortMessageCaptcha = 0;
        public static final int lineCaptcha = 1;
        public static final int circleCaptcha = 2;
    }

    /**
     * 创建验证码
     *
     * @param type 类型 {@link CaptchaFactory }
     * @return {@link AbstractCaptcha}
     */
    public static AbstractCaptcha create(int type) {
        if (NumberUtil.equals(type, Type.lineCaptcha)) {
            return CaptchaCreator.getLineCaptcha();
        } else if (NumberUtil.equals(Type.circleCaptcha, type)) {
            return CaptchaCreator.getCircleCaptcha();
        }
        return CaptchaCreator.getLineCaptcha();
    }
}
